package com.loto.insurance.mis.web.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.loto.insurance.mis.web.db.mapper.SupInfoMapper;
import com.loto.insurance.mis.web.entity.SupInfo;

@Service
public class SupInfoService {
  @Autowired
  SupInfoMapper supInfoMapper;

  public List<SupInfo> getActiveSupList() {
	return supInfoMapper.findActive();
  }

  public SupInfo findActiveById(long supId) {
	return supInfoMapper.findActiveById(supId);
  }

  public List<SupInfo> findAllSup(Map<String, Object> params) {
	return supInfoMapper.findAllSupPager(params);
  }

  public long findAllSupCount(Map<String, Object> params) {
	return supInfoMapper.findAllSupPagerCount(params);
  }

  public boolean addSup(SupInfo supInfo) {
	if (supInfoMapper.findSupByName(supInfo.getSupName()) == null)
	  return supInfoMapper.insertSup(supInfo) > 0;
	else
	  return false;
  }

  public boolean updateSup(SupInfo supInfo) {
	return supInfoMapper.updateSup(supInfo) > 0;
  }

  public SupInfo findSupById(long supId) {
	return supInfoMapper.findSupById(supId);
  }
}
